package com.study.javaFx.model;

import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;

public class Lab {
    private final IntegerProperty labId;
    private final StringProperty labName;
    private final StringProperty location;
    private final IntegerProperty capacity;

    // 支持反序列化的构造方法，确保字段名与后端一致
    @JsonCreator
    public Lab(
            @JsonProperty("labId") Integer labId,
            @JsonProperty("labName") String labName,
            @JsonProperty("location") String location,
            @JsonProperty("capacity") Integer capacity
    ) {
        this.labId = new SimpleIntegerProperty(labId);
        this.labName = new SimpleStringProperty(labName);
        this.location = new SimpleStringProperty(location);
        this.capacity = new SimpleIntegerProperty(capacity);
    }

    // 无参构造方法，供Jackson反序列化使用
    public Lab() {
        this.labId = new SimpleIntegerProperty();
        this.labName = new SimpleStringProperty();
        this.location = new SimpleStringProperty();
        this.capacity = new SimpleIntegerProperty();
    }

    // --- Getters and Property Getters ---

    @JsonProperty("labId")
    public int getLabId() {
        return labId.get();
    }

    public IntegerProperty labIdProperty() {
        return labId;
    }

    @JsonProperty("labName")
    public String getLabName() {
        return labName.get();
    }

    public StringProperty labNameProperty() {
        return labName;
    }

    @JsonProperty("location")
    public String getLocation() {
        return location.get();
    }

    public StringProperty locationProperty() {
        return location;
    }

    @JsonProperty("capacity")
    public int getCapacity() {
        return capacity.get();
    }

    public IntegerProperty capacityProperty() {
        return capacity;
    }

    // --- Setters ---
    @JsonProperty("labId")
    public void setLabId(int labId) { this.labId.set(labId); }
    @JsonProperty("labName")
    public void setLabName(String labName) { this.labName.set(labName); }
    @JsonProperty("location")
    public void setLocation(String location) { this.location.set(location); }
    @JsonProperty("capacity")
    public void setCapacity(int capacity) { this.capacity.set(capacity); }
} 